import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class SystemUIModeExps extends StatelessWidget {
  const SystemUIModeExps({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            ElevatedButton(
              onPressed: () {
                SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
              },
              child: const Text('默认模式'),
            ),
            ElevatedButton(
              onPressed: () {
                SystemChrome.setEnabledSystemUIMode(SystemUiMode.leanBack);
              },
              child: const Text('leanback模式'),
            ),
            ElevatedButton(
              onPressed: () {
                // 在屏幕上边缘向下滑动，退出沉浸模式
                SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
              },
              child: const Text('immersive 模式'),
            ),
            ElevatedButton(
              onPressed: () {
                // 在屏幕上边缘向下滑动，退出沉浸模式
                // 在交互结束后，应用会自动恢复到沉浸模式
                SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
              },
              child: const Text('immersiveSticky 模式'),
            ),
            // manual
            ElevatedButton(
              onPressed: () {
                SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [
                  // SystemUiOverlay.top, // 显示状态栏
                  SystemUiOverlay.bottom, // 显示导航栏
                ]);
              },
              child: const Text('手动模式'),
            ),
          ],
        ),
      ),
    );
  }
}
